package com.oo.parkinglot;
//封装
//可读性
//对象比较

import java.util.Comparator;
import java.util.List;
import java.util.Optional;

public class ParkingSmartBoy extends AbstractParkingRule {


    public ParkingSmartBoy(List<ParkingLot> parkingLots) {
        this.parkingLots = parkingLots;
    }

    @Override
    protected ParkingLot whichParkingLot2Park() {
        Optional<ParkingLot> optionalParkingLot = parkingLots
                .stream()
                .max(Comparator.comparing(ParkingLot::getAvailable));

        return optionalParkingLot.isPresent() ? optionalParkingLot.get() : null;

    }

}
